
$(function(){
	$('#tt').datagrid({
		url: "../carManager/ShowCarlist",
		title: '汽车信息列表',
		width: 1350,
		height: 500,
		fitColumns: true,
		nowrap:false,
		columns:[[
			{field:'id',title:'id',hidden:'true'},
			{field:'car_type',title:'车辆型号',width:150,align:'center'},
			{field:'inprice',title:'进价',width:100,align:'center'},
			{field:'outprice',title:'售价',width:100,align:'center'},
			{field:'color',title:'颜色',width:100,align:'center'},
			{field:'qudong',title:'驱动方式',width:150,align:'center'},
			{field:'made',title:'制造商',width:250,align:'center'},
			{field:'jianjie',title:'车辆简介',width:350,align:'center'},
			{field:'opr1',title:'修改操作',width:100,align:'center',formatter:function(){
				return "<a herf='#' style='color:red;'>修改信息</a>";
			}},
			{field:'opr2',title:'查看详情',width:100,align:'center',formatter:function(){
				return "<a herf='#' style='color:red;'>查看详情</a>";
			}},
			{field:'opr3',title:'删除条目',width:100,align:'center',formatter:function(){
				return "<a herf='#' style='color:red;'>删除</a>";
			}}
		]],
		onClickCell:function(index,field,v){
			if(field=="opr1"){
				var id = $(this).datagrid("getRows")[index].id;
				window.location.href="../carManager/getCarByUpdate?carid="+id;
			}
			if(field=="opr2"){
				var id = $(this).datagrid("getRows")[index].id;
				window.location.href="../carManager/getCarByView?carid="+id;
			}
			if(field=="opr3"){
				var id = $(this).datagrid("getRows")[index].id;
				window.location.href="../carManager/DeleteCar?carid="+id;
			}
		},
		pagination:true,
		rownumbers:true,
		toolbar:[{
			id:"code",
			text:'添加新车型',
			iconCls:'icon-add', 
			handler:function(){
				$('#btnsave').linkbutton('enable');
				//console.log(v[0].code);   供后者传递值进行针对性修改数据
					$('#dd').dialog({    
					    title: '添加新车型',    
					    width: 600,    
					    height: 600,    
					    closed: false,    
					    cache: false,    
					    href: '../carManager/AddCar',     //  对url传值 并且传递给相应的界面
					    modal: true,
					    buttons:[{
							text:'提交',
							iconCls:'icon-ok',
							handler:function(){
								$('#ff').form('submit');
							}
						},{
							text:'清空',
							iconCls:'icon-no',
							handler:function(){
								$('#ff').form('clear');
							}
						},{
							text:'取消',
							handler:function(){
								$('#dd').dialog('close');
							}
						}]
					});    
			}
		
		}],
		loadMsg:"正在努力加载！",
		pageList:[5,10,15,20],
		pageSize:15,
		rowStyler:function(index,row,css){
			if (row.listprice>80){
				return 'background-color:#6293BB;color:#fff;font-weight:bold;';
			}
		}
	});
});